<!-- pages/rental/rental.vue -->
<template>
  <view class="container">
    <!-- 顶部导航栏 -->
<!--    <view class="nav-bar">
      <view class="nav-left" @click="goBack">
        <view class="back-icon">←</view>
      </view>
      <view class="nav-title">辅具租赁</view>
      <view class="nav-right">
        <view class="more-icon">•••</view>
        <view class="circle-icon">⦿</view>
      </view>
    </view> -->

    <!-- 左右分栏布局 -->
    <view class="main-container">
      <!-- 左侧菜单 -->
      <view class="left-menu">
        <view 
          v-for="(item, index) in menuList" 
          :key="index" 
          class="menu-item" 
          :class="{ 'active': activeIndex === index }"
          @click="switchMenu(index)"
        >
          {{ item.name }}
        </view>
      </view>

      <!-- 右侧内容 -->
      <view class="right-content">
        <!-- 产品展示区 -->
        <view class="product-section"  @click="goBack(item)" v-for="(item, index) in gridList" :index="index">
          <view class="product-card">
            <image  class="product-image" :src="item.assisitveImg" mode="aspectFill"></image>
            <view class="product-info">
              <view class="product-tags">
                <view class="tag-new">限时特惠</view>
                <view class="tag-hot">热卖中</view>
              </view>
              <view class="product-name">{{ item.assisitveName }}</view>
              <view class="product-price-area">
                <view class="current-price">¥{{ item.assisitvePrice }}</view>
                <view class="original-price">¥{{ item.assisitveOriginal }}</view>
                <view class="discount-tag">直降44.40元</view>
              </view>
              <view class="product-sales">2.3万+评价 | 99%好评</view>
              <view class="product-service">支持7天无理由退货</view>
            </view>
          </view>
        </view>
		

        <!-- 其他内容区域可根据需求添加 -->
      </view>
    </view>

    <!-- 底部标签栏 -->
    <view class="tabbar">
      <view class="tab-item active" @click="goBack">
        <image class="tab-icon" src="/static/icons/rental-active.png"></image>
        <text>辅具租赁</text>
      </view>
      <view class="tab-item">
        <image class="tab-icon" src="/static/icons/health.png"></image>
        <text>健康档案</text>
      </view>
      <view class="tab-item" @click="myOrder">
        <image class="tab-icon" src="/static/icons/order.png"></image>
        <text>我的订单</text>
      </view>
    </view>
  </view>
</template>

<script>
import * as assistDev from '../../common/api/assistDev.js'
export default {
  data() {
    return {
      activeIndex: 0,
	  gridList: [],
      menuList: [
        { name: '照护产品' },
        { name: '租赁类' },
        { name: '购买类' },
        { name: '热销类' }
      ]
    }
  },
  mounted() {
  	this.queryAllFirstSort()
  },
  methods: {
    goBack(item) {
	const code = item.assisitveName
	 uni.navigateTo({
		 url: "/accessoryRentalPages/pages/index/detils?code=" + code
	 })
	},
	myOrder(item) {
	
	 uni.navigateTo({
		 url: '/accessoryRentalPages/pages/index/myOrder'
	 })
	},
	queryAllFirstSort() {
		assistDev.queryList({
			
		}).then(result => {
			this.gridList = result.data.data || []
		}).catch(error => {
			console.log(error);
		})
	},
    switchMenu(index) {
      this.activeIndex = index
      // 此处可添加切换菜单后的内容更新逻辑
    }
  }
}
</script>

<style lang="scss">
/* 全局样式 */
page {
  background-color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* 顶部导航栏 */
.nav-bar {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background-color: #00C1B2;
  color: #fff;
  position: relative;
  height: 44px;
}

.nav-left {
  width: 30px;
}

.back-icon {
  font-size: 20px;
}

.nav-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
}

.nav-right {
  display: flex;
  align-items: center;
}

.more-icon {
  margin-right: 15px;
  font-size: 18px;
}

.circle-icon {
  font-size: 20px;
}

/* 主容器布局 */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 左侧菜单 */
.left-menu {
  width: 80px;
  background-color: #fff;
}

.menu-item {
  padding: 20px 5px;
  text-align: center;
  font-size: 14px;
  color: #333;
  position: relative;
}

.menu-item.active {
  background-color: #00C1B2;
  color: #fff;
}

/* 右侧内容 */
.right-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 10px; /* 为底部标签栏留出空间 */
}

/* 产品卡片样式 */
.product-card {
  background-color: #fff;
  border-radius: 8px;
  overflow: hidden;
  margin: 10px;
}

.product-image {
  width: 100%;
  height: 200px;
}

.product-info {
  padding: 10px;
}

.product-tags {
  display: flex;
  margin-bottom: 8px;
}

.tag-new, .tag-hot {
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  margin-right: 5px;
  background-color: #FFD700;
  color: #fff;
}

.tag-hot {
  background-color: #FF4500;
}

.product-name {
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 10px;
  color: #333;
}

.product-price-area {
  display: flex;
  align-items: baseline;
  margin-bottom: 8px;
}

.current-price {
  color: #FF4500;
  font-size: 20px;
  font-weight: bold;
  margin-right: 10px;
}

.original-price {
  color: #999;
  font-size: 14px;
  text-decoration: line-through;
}

.discount-tag {
  display: inline-block;
  font-size: 12px;
  color: #fff;
  background-color: #FF4500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.product-sales, .product-service {
  font-size: 12px;
  color: #999;
}

/* 底部标签栏 */
.tabbar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background-color: #fff;
  border-top: 1px solid #eee;
  z-index: 100;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #999;
}

.tab-item.active {
  color: #00C1B2;
}

.tab-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
}
</style>